package server

import (
	"github.com/xhyonline/websocket/mod"
	"gopkg.in/olahol/melody.v1"
)

// BroadcastMultiple 向会话集合广播消息
func (s *server) BroadcastMultiple(msg []byte, users map[string]*mod.User) {
	var sessions = make([]*melody.Session, 0)
	for _, v := range users {
		sessions = append(sessions, v.Session)
	}
	// 全局广播消息
	err := s.Socket.BroadcastMultiple(msg, sessions)
	if err != nil {
		log.Errorf("BroadcastMultiple 方法向集合发送广播消息失败,错误为 %s", err)
	}
}
